#!/usr/bin/env python
# coding: utf-8

class Language(object):
  """A language model."""
  def __init__(self, iso):
    self.dictionary = eval(open('en-ak.links.py').read())

  def detect_subject(self, text):
    tokens = text.split(' ')
    i = 0
    for token in tokens:
      i+= 1
      if token in self.dictionary['verb']:
        return tokens[i - 2]

  def detect_verb(self, text):
    tokens = text.split(' ')
    i = 0
    for token in tokens:
      i+= 1
      if token in self.dictionary['verb']:
        return tokens[i-1]

  def detect_object(self, text):
    tokens = text.split(' ')
    i = 0
    for token in tokens:
      i+= 1
      if token in self.dictionary['verb']:
        return tokens[i]
  